package com.huishen.edrivenew.widget;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

import com.huishen.edrivenew.R;

public class SelectDialog extends Dialog implements View.OnClickListener{

    private RadioGroup group ;
    private Button commit ;
    private int select =0;
    private SelectDailogListener listener ;

    public SelectDialog(Context context ,SelectDailogListener listener) {
		super(context, R.style.dataselectstyle);
		this.listener = listener ;
	}

	public SelectDialog(Context context, int theme) {
		super(context,R.style.dataselectstyle);
	}

	public SelectDialog(Context context, boolean cancelable,
			OnCancelListener cancelListener) {
		super(context,R.style.dataselectstyle);
	}
	 @Override
	    protected void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        this.setContentView(R.layout.dialog_select);
	        registView();
	        init() ;
	    }

	private void registView() {
		group = (RadioGroup)findViewById(R.id.dialog_group);
		commit = (Button)findViewById(R.id.dialog_commit);
	}

	private void init() {
		group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup arg0, int arg1) {
				if(arg1==R.id.dialog_radio1){ //科目二
					select = 2 ;
				}else{ //科目三
					select = 3 ;
				}
			}
		});
		commit.setOnClickListener(this);
	}
	
    public interface SelectDailogListener{
    	public void onClickSelect(int select);
    }

	@Override
	public void onClick(View v) {
		dismiss();
		listener.onClickSelect(select);
		
	}
}
